package com.tencreat.api.controller;

import cn.hutool.json.JSONUtil;
import com.tencreat.common.core.HttpResult;
import com.tencreat.common.core.config.OssClient;
import com.tencreat.common.core.config.OssFactory;
import com.tencreat.common.entity.ImSetting;
import com.tencreat.common.entity.ImSettingBackground;
import com.tencreat.common.entity.ImSettingBackgroundBrief;
import com.tencreat.common.entity.vo.UploadResult;
import com.tencreat.common.service.ImSettingService;
import com.tencreat.common.service.ImUserService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

/**
 * 开放接口
 */
@RestController
@RequestMapping("/open")
public class ImOpenController extends BaseController {


    @Autowired
    ImSettingService imSettingService;
    @Autowired
    ImUserService imUserService;

    /**
     * 配置摘要信息
     * @return
     */
    @PostMapping("/setting/brief")
    public HttpResult<ImSettingBackgroundBrief> infoBrief() {
        ImSetting one = imSettingService.lambdaQuery().eq(ImSetting::getName, ImSettingBackground.KEY).one();
        ImSettingBackgroundBrief bean = JSONUtil.parse(one.getValue()).toBean(ImSettingBackgroundBrief.class);

        return HttpResult.ok(bean);
    }


}
